﻿using AutoMapper;
using CollegeSim.Domain.DTO;
using CollegeSim.Domain.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CollegeSim.Domain.Test
{
    // Author: Ryan Redburn
    // Project: CollegeSim
    // Date: 5/18/2014

    [TestClass]
    public class DomainMapConfigTest
    {
        #region [ Type Maps ]

        [TestMethod]
        public void DomainMapConfig_CourseToDTO_IsValid()
        {
            // Arrange
            var assert = true;
            Mapper.CreateMap<Course, CourseDTO>();

            try
            {
                // Act
                Mapper.AssertConfigurationIsValid();
            }
            catch (AutoMapperConfigurationException)
            {
                assert = false;
            }
            finally
            {
                // Assert
                Assert.IsTrue(assert);
            }
        }

        [TestMethod]
        public void DomainMapConfig_SemesterToDTO_IsValid()
        {
            // Arrange
            var assert = true;
            Mapper.CreateMap<Semester, SemesterDTO>();

            try
            {
                // Act
                Mapper.AssertConfigurationIsValid();
            }
            catch (AutoMapperConfigurationException)
            {
                assert = false;
            }
            finally
            {
                // Assert
                Assert.IsTrue(assert);
            }
        }

        [TestMethod]
        public void DomainMapConfig_SchoolYearToDTO_IsValid()
        {
            // Arrange
            var assert = true;
            Mapper.CreateMap<SchoolYear, SchoolYearDTO>();

            try
            {
                // Act
                Mapper.AssertConfigurationIsValid();
            }
            catch (AutoMapperConfigurationException)
            {
                assert = false;
            }
            finally
            {
                // Assert
                Assert.IsTrue(assert);
            }
        }

        [TestMethod]
        public void DomainMapConfig_SessionToDTO_IsValid()
        {
            // Arrange
            var assert = true;
            Mapper.CreateMap<Session, SessionDTO>();

            try
            {
                // Act
                Mapper.AssertConfigurationIsValid();
            }
            catch (AutoMapperConfigurationException)
            {
                assert = false;
            }
            finally
            {
                // Assert
                Assert.IsTrue(assert);
            }
        }

        [TestMethod]
        public void DomainMapConfig_InstructorToDTO_IsValid()
        {
            // Arrange
            var assert = true;
            Mapper.CreateMap<Instructor, InstructorDTO>();

            try
            {
                // Act
                Mapper.AssertConfigurationIsValid();
            }
            catch (AutoMapperConfigurationException)
            {
                assert = false;
            }
            finally
            {
                // Assert
                Assert.IsTrue(assert);
            }
        }

        [TestMethod]
        public void DomainMapConfig_StudentToDTO_IsValid()
        {
            // Arrange
            var assert = true;
            Mapper.CreateMap<Student, StudentDTO>();

            try
            {
                // Act
                Mapper.AssertConfigurationIsValid();
            }
            catch (AutoMapperConfigurationException)
            {
                assert = false;
            }
            finally
            {
                // Assert
                Assert.IsTrue(assert);
            }
        }

        #endregion
    }
}
